<?
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  PHP DataGrid version 4.2.8 (01.10.2008)                                    #
##  Author & developer:     Leumas Naypoka <leumas.a@gmail.com>                #
##  Developers:             Zewa           <http://www.softic.at>              #
##                          Fcallez        <http://www.innovavirtual.org>      #
##  Lisence:    GNU GPL                                                        #
##  Site:       http://phpbuilder.blogspot.com                                 #
##  Copyright:  Leumas Naypoka (c) 2006-2008. All rights reserved.             #
################################################################################

require_once "../funciones.php";
session_start();


  define ("DATAGRID_DIR", "../datagrid/");                     /* Ex.: "datagrid/" */
  define ("PEAR_DIR", "../datagrid/pear/");                    /* Ex.: "datagrid/pear/" */

  require_once(DATAGRID_DIR.'datagrid.class.php');
  require_once(PEAR_DIR.'PEAR.php');
  require_once(PEAR_DIR.'DB.php');

//Parametros del Sistema
  $auxsql = ""; //almacena las condiciones adicionales para la consulta
  if($_POST['consulTaxDesc'] != "") //Parte de la descripcion Taxonomica
    $auxsql .= " and tax.taxDesc like '%".$_POST['consulTaxDesc']."%' ";
  if($_POST['consulCodTax'] != "") //Codigo Taxonomico
    $auxsql .= " and tax.codigotaxonomia like '%".$_POST['consulCodTax']."%' ";
  if($_POST['clasetx'] != "") //Codigo de la clase taxonomica
    $auxsql .= " and tax.codigoclase = '".$_POST['clasetx']."' ";
  if($_POST['subclase'] != "") //Codigo de la subclase taxonomica
    $auxsql .= " and tax.codigosubclases = '".$_POST['subclase']."' ";
  if($_POST['familia'] != "") //Codigo de la clase taxonomica
    $auxsql .= " and tax.famCod = '".$_POST['familia']."' ";
  if($_POST['gruposTaxo'] != "") //Codigo de la clase taxonomica
    $auxsql .= " and tax.grupCod = '".$_POST['gruposTaxo']."' ";

##  *** creating variables that we need for database connection
  $DB_USER='caweb';
  $DB_PASS='caweb';
  $DB_HOST='localhost';
  $DB_NAME='intranetpccom';

  ob_start();

  $db_conn = DB::factory('mysql');  /* don't forget to change on appropriate db type */
  $result_conn = $db_conn->connect(DB::parseDSN('mysql://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
  if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }
##  *** put a primary key on the first place

    $sql ="
    SELECT tax.codigotaxonomia,tax.taxDesc,cla.descripcion,sub.descripcionsubclase,fam.famDesc,gru.grupDesc from taxonomia tax
    left join clases cla on cla.codigoclase = tax.codigoclase
    left join subclases sub on sub.codigosubclases = tax.codigosubclases and sub.codigoclase = tax.codigoclase
    left join familias fam on fam.famCod = tax.famCod and  fam.codigosubclases = tax.codigosubclases and fam.codigoclase = tax.codigoclase
    left join grupos gru on gru.grupCod = tax.grupCod and gru.famCod = tax.famCod and gru.codigosubclases = tax.codigosubclases and gru.codigoclase = tax.codigoclase
    where tax.estado = 1 $auxsql";

##  *** set needed options and create a new class instance
  $debug_mode = false;        /* display SQL statements while processing */
  $messaging = true;          /* display system messages on a screen */
  $unique_prefix = "f_";      /* prevent overlays - must be started with a letter */
  $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
##  *** set data source with needed options
  $default_order_field = "codigotaxonomia";
  $default_order_type = "";
  $dgrid->dataSource($db_conn, $sql, $default_order_field, $default_order_type);

##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
 $dg_encoding = "latin1";
 $dg_collation = "latin1_swedish_ci";
 $dgrid->setEncoding($dg_encoding, $dg_collation);
##  *** set interface language (default - English)
 $dg_language = "es";
 $dgrid->setInterfaceLang($dg_language);
##  *** set direction: "ltr" or "rtr" (default - "ltr")
 $direction = "ltr";
 $dgrid->setDirection($direction);
##  *** set layouts: 0 - tabular(horizontal) - default, 1 - columnar(vertical)
 $layouts = array("view"=>0, "edit"=>0, "filter"=>1);
 $dgrid->setLayouts($layouts);
##  *** set modes for operations ("type" => "link|button|image")
##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
 $modes = array(
    "add"	 =>array("view"=>false, "edit"=>false, "type"=>"link"),
    "edit"	 =>array("view"=>false, "edit"=>false,  "type"=>"link", "byFieldValue"=>""),
    "cancel"  =>array("view"=>true, "edit"=>true,  "type"=>"link"),
    "details" =>array("view"=>false, "edit"=>false, "type"=>"link"),
    "delete"  =>array("view"=>false, "edit"=>false,  "type"=>"image")
 );
 $dgrid->setModes($modes);

##  *** allow scrolling on datagrid

$scrolling_option = false;
$dgrid->allowScrollingSettings($scrolling_option);
##  *** set scrolling settings (optional)

$scrolling_width = "100%";
$scrolling_height = "100%";
$dgrid->setScrollingSettings($scrolling_width, $scrolling_height);

##  *** allow mulirow operations
 $multirow_option = false;
 $dgrid->allowMultirowOperations($multirow_option);
 $multirow_operations = array(
    "delete"  => array("view"=>false),
    "details" => array("view"=>false)
 );
 $dgrid->setMultirowOperations($multirow_operations);
 $css_class = "blue";
 $css_type = "embedded";
 $dgrid->setCssClass($css_class, $css_type);
 $anotherDatagrids = array("fp_"=>array("view"=>false, "edit"=>true, "details"=>true));
 $dgrid->setAnotherDatagrids($anotherDatagrids);

 $dg_caption = "";
 $dgrid->setCaption($dg_caption);


 $printing_option = false;
 $dgrid->allowPrinting($printing_option);
 $exporting_option = false;
 $dgrid->allowExporting($exporting_option);

 $sorting_option = true;
 $dgrid->allowSorting($sorting_option);
 $paging_option = true;
 $rows_numeration = false;
 $numeration_sign = "Item";
 $dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);
 $bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
 $top_paging = array();
 $pages_array = array("15"=>"15", "25"=>"25", "50"=>"50", "75"=>"75", "100"=>"100", "1000"=>"1000");
 $default_page_size = 100;
 $dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size);

 $filtering_option = false;
 $dgrid->allowFiltering($filtering_option);

 $vm_colimns = array(
  "codigotaxonomia"     =>array("header"=>"Codigo",         "type"=>"label", "width"=>"5px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal"),
  "taxDesc"             =>array("header"=>"Descripcion",    "type"=>"label", "width"=>"10px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal"),
  "descripcion"         =>array("header"=>"Clase",          "type"=>"label", "width"=>"10px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal"),
  "descripcionsubclase" =>array("header"=>"Subclase",       "type"=>"label", "width"=>"10px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal"),
  "famDesc"             =>array("header"=>"Familia",        "type"=>"label", "width"=>"10px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal"),
  "grupDesc"            =>array("header"=>"Grupo",          "type"=>"label", "width"=>"10px","align"=>"left", "wrap"=>"wrap", "text_length"=>"-1", "case"=>"normal")
  );
  $dgrid->setColumnsInViewMode($vm_colimns);

?>

<html>
<head>
        <title>CAWEB - RECOGIDAS</title>
        <meta http-equiv=Content-Type content="text/html; charset=utf-8">
        <META HTTP-EQUIV="refresh" CONTENT="300">
    <?php
        ## call of this method between HTML <HEAD> elements
        $dgrid->WriteCssClass();
    ?>
</head>
<body>
<?php
      $dgrid->Bind();
      ob_end_flush();
?>


</body>
</html>